package com.lzy.mall.search.controller.v1;

import com.lzy.mall.search.service.MallSearchService;
import com.lzy.mall.search.vo.SearchParam;
import com.lzy.mall.search.vo.SearchResult;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lzy
 * @date 2021/10/16 14:16
 */
@RestController
@RequestMapping("/v1")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class VSearchController {
    private final MallSearchService searchService;

    @GetMapping("/list")
    public SearchResult listPage(SearchParam param, HttpServletRequest request){
        // 获取路径原生的查询属性
        param.set_queryString(request.getQueryString());
        return searchService.search(param);
    }
}
